package com.trw.trp.bean;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class OrderScheduleInfo {

	private String condition;
	private String duration;
	// below props only used for lab schedule data
	private Date startTime;
	private Date endTime;
	private String requestNo;
	private long orderId;
	private String modelName;
	private String clientUniqueId;
	private String testLocation;
	private String isOutSourcing;
	private String fixture;
	private String sample;
	private int status;
	private String statusName;

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
		generateStatusName();
	}

	private void generateStatusName() {
		if (status == 3) {
			statusName = OrderBean.OrderStatus.PendingGreenStatus.toString();
		} else if (status == 4) {
			statusName = OrderBean.OrderStatus.GreenStatus.toString();
		} else if (status == 13) {
			statusName = OrderBean.OrderStatus.Completed.toString();
		} else if (status == -3) {
			statusName = OrderBean.OrderStatus.Canceled.toString();
		} else {
			statusName = null;
		}
	}

	public String getStatusName() {
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getRequestNo() {
		return requestNo;
	}

	public void setRequestNo(String requestNo) {
		this.requestNo = requestNo;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public long getOrderId() {
		return orderId;
	}

	public void setOrderId(long orderId) {
		this.orderId = orderId;
	}

	public String getClientUniqueId() {
		return clientUniqueId;
	}

	public void setClientUniqueId(String clientUniqueId) {
		this.clientUniqueId = clientUniqueId;
	}

	public String getSample() {
		return sample;
	}

	public void setSample(String sample) {
		this.sample = sample;
	}

	public boolean isCompleted() {
		if (endTime == null) {
			return false;
		}
		Calendar cal = new GregorianCalendar();
		cal.setTime(endTime);
		cal.add(Calendar.DAY_OF_MONTH, 1);
		return System.currentTimeMillis() >= cal.getTime().getTime();
	}

	public String getTestLocation() {
		return testLocation;
	}

	public void setTestLocation(String testLocation) {
		this.testLocation = testLocation;
	}

	public String getIsOutSourcing() {
		return isOutSourcing;
	}

	public void setIsOutSourcing(String isOutSourcing) {
		this.isOutSourcing = isOutSourcing;
	}

	public String getFixture() {
		return fixture;
	}

	public void setFixture(String fixture) {
		this.fixture = fixture;
	}

	@Override
	public String toString() {
		return "OrderScheduleInfo [condition=" + condition + ", duration="
				+ duration + ", startTime=" + startTime + ", endTime="
				+ endTime + ", requestNo=" + requestNo + ", orderId=" + orderId
				+ ", modelName=" + modelName + ", clientUniqueId="
				+ clientUniqueId + ", testLocation=" + testLocation
				+ ", isOutSourcing=" + isOutSourcing + ", fixture=" + fixture
				+ "]";
	}

}
